package main

import (
	"day7pro/goweb/base6/gee"
	"net/http"
)

// step6 分组控制

func main() {
	r := gee.New()
	r.GET("/index", func(c *gee.Context) {
		c.HTML(http.StatusOK, "<h1>Index Page</h1>")
	})

	v1 := r.Group("/v1")
	v1.GET("/", func(c *gee.Context) {
		// expect /hello?name=xxx
		c.String(http.StatusOK, "<h1>Hello Gee v1</h1>")
	})
	v1.GET("/hello", func(c *gee.Context) {
		// expect /hello?name=xxx
		c.String(http.StatusOK, "hello %s, you are at %s\n", c.Query("name"), c.Path)
	})

	v2 := r.Group("/v2")
	v2.GET("/", func(c *gee.Context) {
		// expect /hello?name=xxx
		c.String(http.StatusOK, "<h1>Hello Gee v2</h1>")
	})
	v2.GET("/hello", func(c *gee.Context) {
		// expect /hello?name=xxx
		c.String(http.StatusOK, "hello2 %s, you are at %s\n", c.Query("name"), c.Path)
	})
	r.Run(":8000")
}
